package com.kiragame.couplescreen.rateapp;

import java.util.Random;

import com.kiragame.couplescreen.utils.KiraGameLog;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class RateAppManager {
	public static RateAppManager mRateAppManager;
	public static Context mContext;
	private static RateApp mRateApp;
	Random rnd = new Random();

	public static RateAppManager getInstance(Context context) {
		if (mRateAppManager == null) {
			mRateAppManager = new RateAppManager(context);
		}
		return mRateAppManager;
	}

	public RateAppManager(Context context) {
		mContext = context;
		setUp();
	}

	private void setUp() {
		if (mRateApp == null) {
			mRateApp = new RateApp(mContext);
		}
	}

	public void show() {
		int random = rnd.nextInt(10);
		KiraGameLog.d("number " + random);
		if (random == 5) {
			mRateApp.show();
		}

	}

	public void rateApp() {
		final String packageName = mContext.getApplicationContext()
				.getPackageName();
		if (packageName == null)
			return;
		Intent t = new Intent(Intent.ACTION_VIEW);
		t.setData(Uri.parse("market://details?id=" + packageName));
		mContext.startActivity(t);
	}
}
